/*
2021-8-19
https://www.acwing.com/problem/content/3812/
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
const int N=1010;
int a[N];
int n;

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        int res=0,sum=1e9;
        
        for(int i=-1;i<=1;i++)
        {
            int cnt=0,x=a[n/2]+i;
            for(int j=0;j<n;j++)
            {
                int t=abs(a[j]-x);
                if(t>1) cnt+=t-1;
            }
            if(cnt<sum)
            {
                res=x,sum=cnt;
            }
        }
        cout<<res<<' '<<sum<<endl;
    }
    return 0;
}
